<template>
	<view class="app-bill">
	<!-- 	<u-navbar :background="background"  
		title-color="#ffffff" back-icon-color="#ffffff"
		:immersive="true" title="订单记录">
		</u-navbar> -->
			<view class="content">
				<!-- <view class="tab-navs">
					<scroll-view class="scroll-term_H" scroll-x="true"  :scroll-left="[index>3?(index-3)*140:0]">
						<block v-for="(item,ind) in tabObjectList" :key="ind">
							<view class="scroll-term-item_H" :class="index == ind ?'act':''" @tap="changItem(item,ind)">
								{{item[1]}}
							</view>
						</block>
					</scroll-view>
				</view> -->
				<template v-if="historyList.length > 0">
					<view class="list">
						<block v-for="(item,index) in historyList" :key="index">
							<view class="list-content">
								<view class="list-content-t">
									<view class="list-content-t-l">
										订单号:{{item.order_no || ''}}
									</view>
									<text>{{item.type==1?'USDT':'USDT+PEP'}}</text>
								</view>
								<view class="list-item-container">
									<view class="list-item-container-li">
										
										<view>{{item.num || 0}} </view>
										<text>数量</text>
									</view>
									<view class="list-item-container-li">
										
										<view>{{item.accrue_income || 0}}</view>
										<text>已收益</text>
									</view>
								</view>
								<view class="list-item-container-b">
									<view class="list-item-container-b-l">
										<view class="list-item-container-b-l-l">买入时间：{{(item.create_time)*1000 | formatDate}}
											
										</view>
										<view class="list-item-container-b-l-l">到期时间：{{item.out_date || '-'}}
											
										</view>
									</view>
									<!-- <button @tap.stop="redemption(item)">赎回</button> -->
								</view>
								
								
							</view>
							
						</block>
						<view class="no-data" v-if="noMore">
							<text>暂无更多数据~</text>
						</view>
					</view>
				</template>
				<template v-else>
					<view class="no-data">
						<image src="/static/imgs/nodata.png" mode="widthFix" lazy-load></image>
						<text>{{i18n.nodata}} </text>
					</view>
				</template>
			</view>
			<u-top-tips ref="message" :type="types" zIndex="999" :navbar-height="statusBarHeight + navbarHeight">
			</u-top-tips>
		<load v-if="showLoadings"></load>
	</view>
</template>

<script>
	import Load from "../../components/common/load.vue"
	import {fetch, showToast, pageback, pageto, forceUpdate, checkLogin} from '@/common/js/util.js'
	import {mapGetters} from 'vuex' 
	let timer;
	export default {
		computed:  {
			i18n() {
				return this.$t('message');
			},
			...mapGetters([
				'getRequestUrl',
				"getLoginInfo",
				'getTextArr',
				'getLangType',
				'getLang'
			])
		},
		data() {
			return {
				background:'#21242D',
				historyList:[],
				page:1,
				showLoadings:false,
				statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
				// 导航栏内容区域高度，不包括状态栏高度在内
				navbarHeight: 44,
				types: '',
			}
		},
		onLoad(){
			
		},
		filters: {
		      formatDate: function (value) {
		        let date = new Date(value);
		        let y = date.getFullYear();
		        let MM = date.getMonth() + 1;
		        MM = MM < 10 ? ('0' + MM) : MM;
		        let d = date.getDate();
		        d = d < 10 ? ('0' + d) : d;
		        let h = date.getHours();
		        h = h < 10 ? ('0' + h) : h;
		        let m = date.getMinutes();
		        m = m < 10 ? ('0' + m) : m;
		        let s = date.getSeconds();
		        s = s < 10 ? ('0' + s) : s;
		        return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
		      }
		    },
		onShow(){
			this.page=1;
			this.historyList =[]
			this.getHistory()
		},
		onReachBottom() {
			this.getHistory()
		},
		methods: {
			 redemption(item){
				 
				
				 
				if(Number(item.bj_tq_status==1)){
					
					
					let _this = this
		          let message='赎回验证';
		          let address = _this.getLoginInfo.address;
		          ethereum.request({
		              method: "personal_sign",
		              params: [message, address],
		          }).then((signature) => {
						
						// _this.number = ''
						 fetch('/api/mall/lcsh', {orderid:item.id}, 'post').then(res => {
							_this.num=''
							if (res.data.code == 1) {
								_this.showTips(res.data.msg,'success')
								_this.page=1;
								_this.historyList =[]
								_this.getHistory()
								}else{
									_this.showTips(res.data.msg,'error')
									// this.comfirm(1)
								}
								
							})
		              
		              //有这个值证明签名了  就可以进行提现操作了
		              //这里进行提现操作
		
		          })
		          .catch((err) => {
					_this.num = ''
		              // 异常  弹个窗
					_this.showTips(_this.getLangType=='en'?' 你无权使用':'你无权使用','success')
		//               alert('你无权使用');
		          });
					
					
					
				
				
				
				
			}else{
				 this.showTips(this.getLangType=='en'?' 暂不可赎回':'暂不可赎回','success')
			}
			},
			getFunction(){
				
			},
			showTips(msg, type) {
				// <!-- type值可选的有primary(默认)、success、info、warning、error -->
				this.$refs.message.type = type
				this.$refs.message.show({
					title: msg
				});
			},
			async getHistory() {
				// this.historyList=[
				// 	{time:'2022/07/03  16:45:32',qgsl:'0.5641 USDT',freeze:'0.5641 USDT'}
				// ]
				
				// return
				await fetch('/api/pledge/pledgeList', {
					page: this.page,
					rows:10,
					type:this.navindex,
					status:2
				}, 'post').then(res => {
					if (res.data.code = 1) {
						// console.log('我zasd');
						if (res.data.data.data == 0) return;
						// console.log('我宰这里');
						if (this.page == 1) {
							this.historyList = res.data.data.data
						} else {
							this.historyList = this.historyList.concat(res.data.data.data)
						}
						this.page++
					}
				})
			},
			back() {
				pageback()
			}
		},
		components: {
			Load
		}
	}
</script>
	
<style lang="scss">
	@import  '@/common/scss/variable.scss';
	@import  '@/common/scss/global.scss';
	.list-content{
		background-color: #1E1F2C;
		border-radius: 16upx;
		margin: 0 44rpx 24rpx;
		
		.list-content-t{
			padding: 0 32rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1rpx solid rgba($color: #ffffff, $alpha: .09);
			.list-content-t-l{
				line-height: 84rpx;
				// padding-left: 28rpx;
				color: $white;
				font-size: 24rpx;
			}
			text{
				color: #F5C249;
				font-size: 28rpx;
			}
			// font-weight: bold;
			// border-bottom: 1rpx solid #2E353E;
		}
		.list-item-container{
			padding: 20rpx 32rpx 26rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.list-item-container-li{
				&:last-of-type{
					text-align: right;
				}
				text{
					color: rgba($color: #ffffff, $alpha: .7);
					font-size: 26rpx;
					line-height: 64rpx;
					display: block;
				}
				view{
					font-size: 30rpx;
					color: $white;
					// line-height: 64rpx;
					&.color1{
						color: #2952F5;
					}
					&.color2{
						color: #46D27B;
					}
				}
				
			}
		}
		.list-item-container-b{
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 20rpx 32rpx 58rpx;
			.list-item-container-b-l{
				.list-item-container-b-l-l{
					&:first-of-type{
						margin-bottom: 18rpx;
					}
					line-height: 34rpx;
					font-size: 24rpx;
					color: rgba($color: #ffffff, $alpha: .6);
				}
			}
			button{
				width: 160rpx;
				height: 84rpx;
				line-height: 84rpx;
				border-radius: 10rpx;
				background: #F5C249;
				color: #1D2431;
				font-size: 34rpx;
				margin: 0;
			}
		}
		.list-item-container-bottom{
			padding: 0 52rpx 46rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			text{
				font-size: 24rpx;
				color: #B6B6B6;
			}
			view{
				margin-top: 22rpx;
				color: #262631;
				font-weight: bold;
				font-size: 30rpx;
				
			}
		}
	}
	.nav-bar{
		padding: 0 30rpx;
		image{
			width: 48rpx;
			height: 48rpx;
			flex-shrink: 0;
		}
	}
	.amount , .status{
		font-size: 26rpx;
		margin-top: 10rpx;
	}
	.no-data{
		margin-top: 130upx;
		text-align: center ;
		image{
			margin: 0 auto 20rpx;
			width: 500upx;
			height: 400upx;
			flex-shrink: 0;
		}
		text{
			display: block;
			font-size: 26rpx;
			color: #BED0DC;
		}
	}
	.list {
		margin-top: 20rpx;
	
		// margin: 40upx 30upx 0;
		// margin-right: 10rpx;
		.list-item {
			
			display: flex;
			align-items: center;
			justify-content: space-between;
			// background-image: url(../../static/imgs/qutation-bg2.png);
			background-size: cover;
			// margin-right: 10rpx;
	
			// &:last-child{
			// 	border-bottom:none;
			// }
			.list-item-i {
				flex: 1;
				padding: 30rpx 42rpx 38rpx 28rpx;
				&:last-child {
					text-align: right;
				}
				view{
					font-size: 30rpx;
					font-weight: bold;
					color: #262631;
					margin-bottom: 16rpx;
				}
				text{
					color: #D6D6D6;
					font-size: 22rpx;
				}
				&.list-item-i-b-t {
					view{
						margin-bottom: 22rpx;
						color: #6E6E6E;
						&.color1{
							color: #2952F5;
						}
						&.color2{
							color: #46D27B;
						}
					}
					
				}
	
	
			}
		}
	}
</style>
